//
// Created by xili on 2024/8/3 16:49.
// Go big or go home.
//

using namespace std;

class Solution {
public:
    int commonFactors(int a, int b) {
        int ans = 1;
        int g = gcd(a, b);
        for (int i = 2; i <= g; i++) {
            if (a % i == 0 && b % i == 0) {
                ans++;
            }
        }
        return ans;
    }

    int gcd(int a, int b) {
        return b == 0 ? a : gcd(b, a % b);
    }
};